#!/bin/bash

PID=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/process_id:/ {print $2}')
cpu_sys=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/used_cpu_sys:/ {print $2}')
mem=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/used_memory_rss_human:/ {print $2}')
rece_con=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/total_connections_received/ {print $2}')
reje_con=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/rejected_connections:/ {print $2}')
net_input=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/total_net_input_bytes:/ {print $2}')
net_output=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/total_net_output_bytes:/ {print $2}')
keys_hits=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/keyspace_hits:/ {print $2}')
keys_misses=$(redis-cli -h 192.168.140.21 -p 6380 info | awk -F: '/keyspace_misses:/ {print $2}')
echo -e "PID：${PID}\tCPU：${cpu_sys}\t内存：${mem}\t接收的连接：${rece_con}\t拒绝的连接：${reje_con}\n网卡流入流量：${net_input}\t网卡流出流量：${net_output}\t缓存命中：${keys_hits}\t丢失：${keys_misses}"| sed 's|\r||g'
